import { Component, OnInit } from '@angular/core';
import { BaselineService } from 'src/app/core/service/baseline.service';
import { ActivatedRoute } from '@angular/router';

@Component({
  selector: 'app-baseline-detail',
  templateUrl: './baseline-detail.component.html',
  styleUrls: ['./baseline-detail.component.scss']
})
export class BaselineDetailComponent implements OnInit {
  containerId = '';
  serverId = '';
  dataSet: any;
  constructor(
    private baselineService: BaselineService,
    private routeInfo: ActivatedRoute,
  ) { }

  getBaselineDetailPage(reset: boolean = false): void {
    console.log('安全基线.进入', this.containerId);
    if (this.containerId.length < 33 && this.containerId.length > 0 && this.serverId.length < 33 && this.serverId.length > 0) {
      this.baselineService.getBaselineDetailPage(this.serverId, this.containerId).subscribe(
        (BaselineDetailPage) => {
          console.log(BaselineDetailPage, '<--- BaselineDetailPage');
          this.dataSet = BaselineDetailPage;
          /*  console.log(this.dataSet.servers); */
          /* if (this.dataSet.servers === null || this.dataSet.servers !== undefined || this.dataSet.servers !== '') {
            this.dataSet.servers.push(
              { serverId: '', serverName: '暂无记录' }
            );
          } */
        }
      );
    }
  }

  ngOnInit() {
    this.containerId = this.routeInfo.snapshot.queryParams['containerId'];
    this.serverId = this.routeInfo.snapshot.queryParams['serverId'];
    console.log('this.serverId ==>' + this.serverId + '...,this.containerId' + this.containerId);
    this.getBaselineDetailPage();
  }

}
